package cn.alibab.inspect.service.impl;


import cn.alibab.common.model.PageBean;
import cn.alibab.common.model.PageResult;
import cn.alibab.common.model.R;
import cn.alibab.common.service.BaseService;
import cn.alibab.inspect.mapper.ReportMapper;
import cn.alibab.inspect.model.Report;
import cn.alibab.inspect.model.ReportExample;
import cn.alibab.inspect.service.ReportService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author LHW
 * @create 2020-07-16 22:41
 */
@Service
public class ReportServiceImpl extends BaseService implements ReportService {

    private final ReportMapper reportMapper;
    public ReportServiceImpl(ReportMapper reportMapper) {
        this.reportMapper = reportMapper;
    }

    @Override
    public R selRep(Integer id, PageBean pageBean){
        ReportExample example=new ReportExample();
        ReportExample.Criteria criteria=example.createCriteria().andIdGreaterThanOrEqualTo(1);
        if (!StringUtils.isEmpty(id)) {
            criteria.andReprotnameEqualTo("%" + id + "%");
        }
        PageInfo<Report> Info = new PageInfo<>(reportMapper.selectByExample(example));
        return R.ok(new PageResult<Report>(Info.getTotal(),Info.getList()));


    }

}
